﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityComponentSystem.Framework;
using EntityComponentSystem.Framework.Math;
using EntityComponentSystem.Framework.Json;

namespace ECS.Demos.Tetris.Components
{
    public static class Conversions
    {
        public static JsonObject ToJsonObject(this ColorEx input)
        {
            var jo = new JsonObject();
            jo["a"] = input.a;
            jo["r"] = input.r;
            jo["g"] = input.g;
            jo["b"] = input.b;
            return jo;
        }

        public static ColorEx ToColorEx(this JsonObject input)
        {
            return new ColorEx(input["a"], input["r"], input["g"], input["b"]);
        }

        public static Vector2 ToVector2(this JsonObject input)
        {
            return new Vector2(input["x"], input["y"]);
        }
    }
}
